package com.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mapper.UserMapper;
import com.pojo.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    @Override
    public User login(String account, String password) {
        return userMapper.login(account,password);
    }

    @Override
    public PageInfo<User> selectAll(int pageNum, String authtatus) {
        PageHelper.startPage(pageNum,3);
        List<User> users = userMapper.selectAll(authtatus);
        PageInfo<User> pageInfo = new PageInfo<>(users);
        return pageInfo;
    }

    @Override
    public User selectById(long id) {
        return userMapper.selectById(id);
    }

    @Override
    public int updateUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public User selectByAccount(String account) {
        return userMapper.selectByAccount(account);
    }

    @Override
    public int insertUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int deleteUser(long id) {
        return userMapper.deleteUser(id);
    }

    @Override
    public int zzupdate(User user) {
        return userMapper.zzupdate(user);
    }

    @Override
    public int updateAuthtatus(long id, long authtatus) {
        return userMapper.updateAuthtatus(id,authtatus);
    }
}
